import Vue from 'vue'
import App from './App.vue'
import router from './router'
import moment from 'moment'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './plugins/element.js'

// -------------------------------字体图标css样式
import './assets/fonts/iconfont.css'

// ------------------------------全局css样式
import './assets/css/global.css'

// ------------------------------树状表格依赖
import ZKTable from 'vue-table-with-tree-grid'

// -------------------------------配置 axios
import axios from 'axios'
// -------------------------------导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor /* { default global options } */)

// 手动注册
Vue.component('tree-table', ZKTable)

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 设置请求拦截器,为每一次请求挂载 Authorization 字段,保证正常访问有权限的接口
axios.interceptors.request.use(config => {
  // 在请求头中中添加 token 字符串,代表登录状态
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios

// 时间过滤器
Vue.filter('dateFormat', (val) => {
  return moment.unix(val).format('YYYY-MM-DD HH:mm:ss')
})

Vue.use(ElementUI)
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
